# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=emp3r0r
pkgver=v1.27.2.r1.gfb2d678
pkgrel=1
pkgdesc='Linux post-exploitation framework made by linux user.'
arch=('x86_64')
groups=('blackarch')
url='https://github.com/jm33-m0/emp3r0r'
license=('MIT')
depends=('tmux' 'bash')
makedepends=('git' 'go')
source=("git+https://github.com/jm33-m0/emp3r0r.git")
sha512sums=('SKIP')

pkgver() {
    cd $pkgname

    git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
    cd $pkgname/core
    ./emp3r0r --build
    cp ./emp3r0r /tmp/emp3r0r-build/
    cp -r ./tmux /tmp/emp3r0r-build/
    cp -r ./modules /tmp/emp3r0r-build/
    
}

package() {
    cd /tmp/emp3r0r-build/
	mkdir -p "$pkgdir/usr/lib/emp3r0r/build" || error "Failed to mkdir $build_dir"
    cp -avR tmux "$pkgdir/usr/lib/emp3r0r" || error "tmux"
    cp -avR modules "$pkgdir/usr/lib/emp3r0r" || error "modules"
    cp -avR stub* "$pkgdir/usr/lib/emp3r0r/build" || error "stub"
    # emp3r0r binaries
    chmod 755 "emp3r0r" cc.exe cat.exe
    mkdir -p "$pkgdir/usr/bin/"
    cp -avR "emp3r0r" "$pkgdir/usr/bin/emp3r0r" || error "$0"
    cp -avR cc.exe "$pkgdir/usr/lib/emp3r0r/emp3r0r-cc" || error "emp3r0r-cc"
    cp -avR cat.exe "$pkgdir/usr/lib/emp3r0r/emp3r0r-cat" || error "emp3r0r-cat"
}
